home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-06-18 | 2.0 KB | 59 lines | [TEXT/CWIE] |
- (*
- Problem 07 - Graph
-
- procedure GraphInit( var graph: Handle; verrticies: UInt32 );
- procedure GraphAddDirectedEdge( graph: Handle; vertex1, vertex2: UInt32 );
- procedure GraphFindRoute( graph: Handle; vertex1, vertex2: UInt32; var
- verticies: Handle );
-
- Your task is to write a set of routines to create and traverse a directed
- graph.
-
- GraphInit creates a new, empty directed graph ready to accept directed edges
- with verrticies verticies.
-
- GraphAddDirectedEdge adds a directed edge from vertex1 to vertex2
-
- GraphFindRoute find a route from vertex1 to vertex2. If such a route exists,
- then verticies is returns as a real Mac handle to an array of UInt32s, the
- first is vertex1, the last is vertex2. Each successive vertex must have
- previously had an edge added with GraphAddDirectedEdge. If no route exists,
- return nil for verticies. No vertex should appear more than once in the
- verticies handle, except for the case where vertex1 is the same as vertex2, in
- which case you must find a circular route from vertex1 back to itself and so
- vertex1 will appear exactly twice, once at the start and once at the end of the
- verticies handle.
-
- All the graph information must be stored in the real Mac memory manager handle
- - it will be disposed with DisposeHandle and that must release all memory, so
- dont store any extra information outside the handle. Also, you must be able to
- deal with having multiple graphs instantiated simultaneously.
- *)
-
- unit Solution;
-
- interface
-
- // Do not modify the interface
-
- uses
- Types, Files;
-
- type
- UInt32Array = array[0..0] of UInt32;
- UInt32ArrayPtr = ^UInt32Array;
- UInt32ArrayHandle = ^UInt32ArrayPtr;
-
- procedure GraphInit( var graph: Handle; verticies: UInt32 );
- procedure GraphAddDirectedEdge( graph: Handle; vertex1, vertex2: UInt32 );
- procedure GraphFindRoute( graph: Handle; vertex1, vertex2: UInt32; var verticies: UInt32ArrayHandle );
-
-
- implementation
-
- // Fill in your solution and then submit this folder
-
- // Team Name: FILL IN YOUR TEAM NAME!
-
- end.
-